-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix: CLI context pollution between sessions #8420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Resolves context pollution issue where CLI sessions would retain state from previous invocations, causing responses to reference conversations that should have been isolated. Changes: - Added SessionManager.reset() static method for proper cleanup - Updated initializeChatHistory() to create new session by default - Clear undo/redo stacks in ChatHistoryService on initialization - Added comprehensive session isolation tests Fixes CON-4530 Co-authored-by: Username <nate@continue.dev> Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
The vi.mock setup already properly types the uuid v4 function to return string, so the 'as any' type assertions are unnecessary and were creating TypeScript smell in the test file. This change improves type safety while maintaining the same test behavior. Co-authored-by: Username <nate@continue.dev> Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 5 files
Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
…ontinuebot/con-4530
The tests are sufficient to verify the bug exists. The code changes were treating symptoms rather than fixing the root cause. Each CLI invocation should be a fresh Node.js process, so state pollution shouldn't occur between separate 'cn' commands in the first place. The added tests will catch when the actual architectural issue gets properly fixed. Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
4e41deb to
9c3f250
Compare
bdougie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally had Continue generate a fix, but the fix wasn't doing anything. Instead I am opting to keep the tests as they validate that context pollution isn't happening and we can look to these if this is reported in the future.
This PR will at least resolve the discussion that this was reported in.
RomneyDa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look like only test file and package lock changes are present now
|
🎉 This PR is included in version 1.32.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.29.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Adds comprehensive tests to validate session isolation in the Continue CLI. These tests verify that the bug reported in #7916 exists and provide regression coverage for future fixes.
Background
As reported in #7916 and CON-4530, there were concerns about the CLI potentially maintaining state across separate invocations. This would mean:
cn "Tell me about dogs", having a conversation, then exitingcn "What were we discussing?"in a new sessionChanges
Tests Added (session.test.ts)
Three new test cases validate session isolation:
--resumecreates a clean session with no history from previous invocationsPackage Updates
package-lock.jsonNote on Implementation
Initial commits included code changes attempting to fix the root cause through
SessionManager.reset()andChatHistoryServicecleanup. However, these changes were treating symptoms rather than the architectural root cause. Since each CLI invocation should be a fresh Node.js process, persistent state pollution shouldn't occur architecturally.The tests serve as:
Testing
Run the new tests:
npm test -- session.test.tsRelated Issues
Addresses #7916
Relates to CON-4530